package cn.zlj.pethome.user.controller;

import cn.zlj.pethome.basic.util.AjaxResult;
import cn.zlj.pethome.user.dto.AccountDto;

import cn.zlj.pethome.user.dto.WechatLoginDto;
import cn.zlj.pethome.user.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Map;


@RestController
@RequestMapping("/login")
public class AccountLoginController {
    @Autowired
    LoginService loginService;
    @PostMapping("/account")
    public AjaxResult accountLogin(@RequestBody @Valid AccountDto accountDto){
        Map<String, Object> map = loginService.accountLogin(accountDto);
        return AjaxResult.me().success(map);
    }
    @PostMapping("/wechat")
    public AjaxResult wechatLogin(@RequestBody @Valid WechatLoginDto params){

        return loginService.wechatLogin(params);
    }
    @PostMapping("/wechat/binder")
    public AjaxResult binder(@RequestBody  WechatLoginDto wechatLoginDto){
        Map<String, Object> map = loginService.binder(wechatLoginDto);
        return AjaxResult.me().success(map);
    }

}
